package org.example.tomcat;

import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.WriteListener;

import java.io.IOException;

public class ResponseServletOutputStream extends ServletOutputStream {

    //响应体缓存
    private byte[] bytes = new byte[1024];
    private int index = 0;



    @Override
    public boolean isReady() {
        return false;
    }

    @Override
    public void setWriteListener(WriteListener writeListener) {

    }

    @Override
    public void write(int i) throws IOException {
        bytes[index++] = (byte) i;

    }



    public byte[] getBytes() {
        return bytes;
    }

    public int getIndex() {
        return index;
    }
}
